# -*- coding: utf-8 -*-
# https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe566d7c50a4d2cf9&redirect_uri=http%3A%2F%2F073fac6f.ngrok.io%2Fauth&response_type=code&scope=snsapi_base&state=STATE
from __future__ import unicode_literals
import os

debug = False if os.name == 'posix' else True


def hostname():
    sys = os.name

    if sys == 'nt':
        host_name = os.getenv('computername')
        return host_name

    elif sys == 'posix':
        host = os.popen('echo $HOSTNAME')
        try:
            host_name = host.read()
            return host_name
        finally:
            host.close()
    else:
        return 'Unkwon hostname'


host_name = hostname()


class Base:
    baseUrl = "http://127.0.0.1/wx" if debug else "http://weixin.pbani.com/wx"
    templateUrl = '../../templates/dist/' if debug else "../../templates/dist"
    thirdUrl = "http://118.24.98.157:9388/tao/?r=tao/"


WX = {
    "appid": 'wxe566d7c50a4d2cf9',
    "appsecret": '22e51f3c77de185205a9a0cf51c942dc',
    "Token": '123456',
    "redirect_url": "/auth",
    "base_url": "http://073fac6f.ngrok.io",
    "chat_auth_url": "record"
}

MessageList = [
    "欢迎进入pbani设备管理微信公众号,",
]
db = {
    "host": "118.24.98.157",  # "localhost",
    "port": 28001  # 27017
}

QCloud = {
    "app_id": 1251758307,
    "secret_id": 'AKIDhJl2AOgTF7pNlytrZFk3B7sSt9FARcCg',
    "secket_key": 'YzFJCucfbMwLZfbO0Sk072mLjw32rVyH',
    "region": 'gz',
    "dir": 'wx',
    "bucket": 'tao'
}

serverIp = "118.24.98.157"
redisIp = "118.24.98.157"
redisPort = 8999
serverUrl = 'http://weixin.pbani.com/tao/?r=tao/'


class Mysql:
    ip = "118.24.98.157"
    port = 5858
    user = 'root'
    password = 'Q~123456y'


AES_KEY = os.getenv('WECHAT_AES_KEY', '54mseptuJOgkN01ZiVSF8ZRe6gQ1IIda0qYdxjLxuZQ')
APPID = os.getenv('WECHAT_APPID', 'wxe566d7c50a4d2cf9')
redisHash = 'tao.online'

if __name__ == '__main__':
    import redis

    client = redis.Redis(host=redisIp, port=redisPort, db=0)
    print("Connection to server successfully!")
    dicKeys = client.keys("*")
    print(dicKeys)

    hashVal = client.hget('tao.online', 'sdfsdf7829fa')
    print("Get hash value:", hashVal)
